package com.qf.shop.controller;

import com.qf.shop.annotation.ProcessInfo;
import com.qf.shop.service.ICountDatabaseService;
import com.qf.shop.vo.ReturnCartCount;
import com.qf.shop.vo.ReturnCount;
import com.qf.shop.vo.ReturnPrice;
import com.qf.shop.vo.ReturnUserCount;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/count")
public class CountDatabaseController {

    private ICountDatabaseService iCountDatabaseService;

    public CountDatabaseController(ICountDatabaseService iCountDatabaseService) {
        this.iCountDatabaseService = iCountDatabaseService;
    }


    @GetMapping("/goodsCount")
    @ProcessInfo("查询商品的销售数据")
    public List<ReturnCount> getGoodsCount(){
        List<ReturnCount> goodsCount = iCountDatabaseService.getGoodsCount();
        return goodsCount;
    }

    @GetMapping("/goodsPrice")
    @ProcessInfo("查询商品的销售额")
    public List<ReturnPrice> getGoodsPrice(){
        List<ReturnPrice> goodsPrice = iCountDatabaseService.getGoodsPrice();
        return goodsPrice;
    }

    @GetMapping("/cartCount")
    @ProcessInfo("查询前十购物车数据")
    public List<ReturnCartCount> getCartCount(){
        List<ReturnCartCount> cartCount = iCountDatabaseService.getCartCount();
        return cartCount;
    }

    @GetMapping("/UserCount")
    @ProcessInfo("查询全部的用户日增数据")
    public List<ReturnUserCount> getUserCount(){
        List<ReturnUserCount> userCount = iCountDatabaseService.getUserCount();
        return userCount;
    }

    @GetMapping("/UserCount30")
    @ProcessInfo("查询30天内的用户日增数据")
    public List<ReturnUserCount> getUserCount30(){
        List<ReturnUserCount> userCount30 = iCountDatabaseService.getUserCount30();
        return userCount30;
    }

    @GetMapping("/UserCount7")
    @ProcessInfo("查询7天内的用户日增数据")
    public List<ReturnUserCount> getUserCount7(){
        List<ReturnUserCount> userCount7 = iCountDatabaseService.getUserCount7();
        return userCount7;
    }




}
